import { _decorator, Component, Label, Node } from 'cc';
import { StaminaSystem } from './StaminaSystem';
import { losTools } from '../Tools/losTools';
const { ccclass, property } = _decorator;

@ccclass('StaminaShowUI')
export class StaminaShowUI extends Component {
    @property(Label)
    public countDownLabel: Label = null!;

    @property(Label)
    public staminaLabel: Label = null!;

    @property(Node)
    public infiniteStaminaNode: Node = null!;

    start() {

    }
    /**
     * onAddClick
     */
    public onAddClick() {
        losTools.showBuyStaminaUI()
    }

    update(deltaTime: number) {
        this.staminaLabel.string = `${StaminaSystem.instance.getStamina()}`;
        this.countDownLabel.string = `${StaminaSystem.instance.getRecoveryLeftTime()}`;
        if (StaminaSystem.instance.isInfiniteStamina()) {
            this.infiniteStaminaNode.active = true;
            this.staminaLabel.node.active = false;
        }
        else {
            this.infiniteStaminaNode.active = false;
            this.staminaLabel.node.active = true;
        }
    }
}